home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 3265 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  3.2 KB

  1. Path: news.ccs.queensu.ca!news
  2. From: dmurdoch@mast.queensu.ca (Duncan Murdoch)
  3. Newsgroups: comp.lang.c++,comp.lang.pascal.delphi.misc
  4. Subject: Re: C++ with Zapp vs. Delphi
  5. Date: Tue, 23 Jan 1996 03:21:13 GMT
  6. Organization: Queen's University, Kingston
  7. Message-ID: <31044e99.17184110@130.15.126.54>
  8. References: <4coar6$d4n@sun4.bham.ac.uk> <4coip7$69s@news1.usa.pipeline.com> <DBk8wg2yqjbB083yn@iaccess.za> <4d7pmb$48c8@tigger.cc.uic.edu> <4dk38h$gdr@merlin.delphi.com> <4dksp1$3d6c@tigger.cc.uic.edu> <30fe666e.3349285@130.15.126.54> <4durk2$2r54@tigger.cc.uic.edu> <31038877.2364473@130.15.126.54> <4e15b0$1g68@tigger.cc.uic.edu>
  9. NNTP-Posting-Host: free1-slip203.tele.queensu.ca
  10. X-Newsreader: Forte Agent .99c/16.141
  11.  
  12. olczyk@sunphy1 (Lambert Schoonveld) wrote:
  13.  
  14. >In your method what if the comparison needs to use private data in the object?
  15.  
  16. Then it would just access it.  The specialized list would normally be
  17. declared in the same unit as the object type it was sorting (or the
  18. base class for a hierarchy), so it would have access to private fields
  19. (like a "friend" in C++).
  20.  
  21. Yes, this leaves the possibility that you might want to put a
  22. descendant object into the list, and have the sort order depend on
  23. some private part of the descendant object, and have the descendant
  24. object in some other unit so it wasn't a friend.  
  25.  
  26. In a case like that I would have to add a method to the base class to
  27. produce the key, and override it in the descendant, so I might as well
  28. just have the Compare method in the object the way you do.
  29.  
  30. However, I have a hard time imagining a situation where the sort order
  31. depends on something that's invisible to the sorter, so I'm not going
  32. to lose sleep over this possibility.
  33.  
  34. >: Remember, I'm reading this in the Delphi group, and I'm not
  35. >: particularly familiar with C++ jargon.
  36. >
  37. >Strange since it's basis is in Smalltalk.
  38.  
  39. Well, I'm not familiar with Smalltalk either, and I just didn't guess
  40. that you would use Smalltalk jargon when talking to people about C++
  41. and Delphi.
  42.  
  43. >You have a class called model. It's purpose is to hlod data of some
  44. >form ( say a record in a database). You have a set of classes
  45. >called 'views' (say dataaware components). When you create a view
  46. >it is associated to a model object. When the data stored in the model object
  47. >changes, it updates the views. When a view changes it updates the model.
  48.  
  49. You asked how I would implement this in Delphi, which doesn't have MI.
  50.  
  51.  
  52. The normal way to do it would be to have your views be clients of the
  53. model class, i.e. each would have a reference to an object of the
  54. model class as one of its fields.  The data would be exposed as
  55. "properties", which look to the outside like fields, but which are
  56. implemented using Get and Set methods.  When you wanted to look at
  57. field Name, you'd just look at the Name property of the view, and the
  58. Get method would get the Name out of the model object.  When you set
  59. the Name in the view, the Set method would set the Name in the model.
  60.  
  61. It's really all pretty straightforward.  MI isn't needed.
  62.  
  63. I know there are cases where MI is helpful, but sorted lists and views
  64. of data objects aren't among them.
  65.  
  66. Since this thread is getting pretty repetitive, and your mailer is
  67. broken so we can't go to email, I'm going to bow out now.  It was nice
  68. talking to you.
  69.  
  70. Duncan Murdoch
  71.